<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <script>
    // const obj = {
    //   name: "why",
    //   age: 18,
    //   // 1.和hasOwnProperty的区别一: 防止对象中也有一个自己的hasOwnProperty方法
    //   hasOwnProperty: function() {
    //     return "abc"
    //   },
    //   __proto__: {
    //     address: "广州市"
    //   }
    // }

    // console.log(obj.name, obj.age)
    // console.log(obj.address)

    // console.log(obj.hasOwnProperty("name"))
    // console.log(obj.hasOwnProperty("address"))

    // console.log(Object.hasOwn(obj, "name"))
    // console.log(Object.hasOwn(obj, "address"))


    // 2.和hasOwnProperty的区别二:
    const info = Object.create(null)
    info.name = "why"
    // console.log(info.hasOwnProperty("name"))
    console.log(Object.hasOwn(info, "name"))

  </script>

</body>
</html>